R for Business Analytics by A. Ohri

R for Business Analytics by A. Ohri

Author:A. Ohri
Language: eng
Format: epub
Publisher: Springer New York, New York, NY


5.4.1.1 Histograms

Histograms are commonly used to show the distribution of data for variables and for probability estimation. Creating a histogram in R is as simple as typing hist(dataset$variable):

¿ data(iris)

¿ hist(iris)

Error in hist.default(iris) : ‘x’ must be numeric

¿ names(iris) [1] ”Sepal.Length” ”Sepal.Width” ”Petal.Length” ”Petal.Width” ”Species”

¿ str(iris) ’data.frame’: 150 obs. of 5 variables:

$ Sepal.Length: num 5.1 4.9 4.7 4.6 5 5.4 4.6 5 4.4 4.9...

$ Sepal.Width : num 3.5 3 3.2 3.1 3.6 3.9 3.4 3.4 2.9 3.1...

$ Petal.Length: num 1.4 1.4 1.3 1.5 1.4 1.7 1.4 1.5 1.4 1.5...

$ Petal.Width : num 0.2 0.2 0.2 0.2 0.2 0.4 0.3 0.2 0.2 0.1...

$ Species : Factor w/ 3 levels ”setosa”,”versicolor”,..: 1 1 1 1 1 1 1 1 1 1...

¿ hist(iris$Sepal.Length)



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.